package com.itheima.d2_udp1;

import java.io.IOException;
import java.net.*;

/**
 * UDP客户端：发送数据
 */
public class Client {
    public static void main(String[] args) throws IOException {
        //1.创建DatagramSocket对象，准备发送数据
        DatagramSocket socket = new DatagramSocket(10086);
        //2.创建数据，并把数据打包
        byte[] bytes = new String("我是卢宇浩").getBytes();
        InetAddress address = InetAddress.getByName("192.168.38.230");
        DatagramPacket packet = new DatagramPacket(bytes,bytes.length,address , 8080);
        //3.发送数据
        socket.send(packet);
        //4.释放资源
        socket.close();

    }
}
